class DataFile < ActiveRecord::Base
  def self.save(upload,path)
    Dir.chdir(path)
    if(upload['datafile'] != "") then 
      name =  upload['datafile'].original_filename
      if(name.index(/\.[zip|rar|tgz|tar\.gz]/).nil?) then 
        false
      else
        path = File.join(path, name)
        File.open(path, "wb") { |f| f.write(upload['datafile'].read) }
        path
      end
    else
      false
    end
  end
end
